FROM alpine:latest as builder

WORKDIR /app
COPY . .

# 安装依赖包
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add nodejs=14.16.1-r1 \
&& apk add npm=14.16.1-r1 \
&& npm config set registry https://registry.npm.taobao.org \
&& npm install
RUN npm run build

# size ≈ 64MB+
# FROM alpine:latest

# EXPOSE 8080

# WORKDIR /data

# # 安装依赖包
# RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
# && apk add nodejs=14.16.1-r1 \
# && apk add npm=14.16.1-r1 \
# && npm install serve-static

# COPY server.js .
# COPY --from=builder /app/dist/ ./dist
# ENV PORT=8080
# CMD node /data/server.js

# size ≈ 23MB+
FROM nginx:1.21.0-alpine
COPY --from=builder /app/dist/ /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
